<!-- 策略 -->
<template>
  <div class="strategy">
    <el-row :gutter="20">
      <el-col :span="2"><div class="grid-content bg-purple"><span>策略搜索：</span></div></el-col>
      <el-col :span="4"><div class="grid-content bg-purple"> <el-input v-model="input" placeholder="请输入内容" /></div></el-col>
      <el-col :span="18"><div class="grid-content bg-purple"> <el-button type="primary" icon="el-icon-search">搜索</el-button></div></el-col>
    </el-row>
    <el-table
      :data="tableData"
      style="width: 100%"
    >
      <el-table-column
        prop="policyId"
        label="序号"
        width="180"
      />
      <el-table-column
        prop="policyName"
        label="策略名称"
        width="180"
      />
      <el-table-column
        prop="discount"
        label="策略方案"
      />
      <el-table-column
        prop="updateTime"
        label="创建日期"
      ><template slot-scope="scope">
        <span>{{ scope.row.updateTime.replace('T', ' ').replace('-', '.') }}</span>

      </template></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            size="mini"
            @click="handleMessage(scope.$index, scope.row)"
          >查看详情</el-button>
          <el-button
            size="mini"
            @click="handleEdit(scope.$index, scope.row)"
          >修改</el-button>
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
// 导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
import { PolicySearchtAPI } from '@/api/strategy'
export default {
  name: 'Strategy',
  components: {},
  props: {
  },
  data() {
    return {
      input: '',
      tableData: []
    }
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {},
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {
    this.PolicySearcht()
  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {

  },
  beforeCreate() {}, // 生命周期 - 创建之前
  beforeMount() {}, // 生命周期 - 挂载之前
  beforeUpdate() {}, // 生命周期 - 更新之前
  updated() {}, // 生命周期 - 更新之后
  beforeDestroy() {}, // 生命周期 - 销毁之前
  destroyed() {}, // 生命周期 - 销毁完成
  activated() {},
  // 方法集合
  methods: {
    async PolicySearcht() {
      const { data } = await PolicySearchtAPI({
        pageIndex: 1,
        pageSize: 10

      })
      this.tableData = data.currentPageRecords
      // console.log(data.currentPageRecords)
    },
    handleMessage(index, row) {
      console.log(index, row)
    },
    handleEdit(index, row) {
      console.log(index, row)
    },
    handleDelete(index, row) {
      console.log(index, row)
    }
  } // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>
<style scoped lang='scss'>

</style>
